Tighten rfc5322 dot placement, fix empty quoted local-part, test length toggle - #63
Merged
Merged
Conversation
…th toggle
Three correctness/config improvements surfaced by differential testing against
a reference validator and the dominicsayers/isemail gold-standard corpus.
- rfc5322() now enforces dot-atom local-part structure (§3.2.3): leading,
trailing, and consecutive dots are rejected, matching the real obs-local-part
ABNF (§4.4, non-empty words). The permissive behavior stays available via
rfc2822() or withAllowObsLocalPart(true). Obs-dot testspec cases moved from
`normal` to `relaxed` mode accordingly.
- Empty quoted local-part (""@Domain) is now recognized as quoted, so
rejectEmptyQuotedLocalPart (default false) actually controls its acceptance.
The closing-quote handler records the quote explicitly; a display-name quote
resets the flag so the real local-part stays unquoted.
- Documented + tested that enforceLengthLimits(false) disables the 64-octet
local-part limit (withLengthLimits() for custom limits) — already supported.
91 -> 94 tests, PHPStan level 8 / Psalm / cs all clean.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #63 +/- ##
============================================
+ Coverage 92.55% 92.87% +0.32%
- Complexity 380 381 +1
============================================
Files 6 6
Lines 981 983 +2
============================================
+ Hits 908 913 +5
+ Misses 73 70 -3
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three correctness/config improvements to local-part handling, surfaced by differential testing against a reference RFC validator and the dominicsayers/isemail gold-standard corpus.
Changes
rfc5322()dot-atom enforcement (behavior change)rfc5322()now rejects a leading, trailing, or consecutive dot in the local part (.a@,a.@,a..b@), enforcing dot-atom per RFC 5322 §3.2.3. This matches the actual obs-local-part ABNF (§4.4:word *("." word), words non-empty) — obs-local-part never permitted empty words either.Escape hatch: the previous permissive dot placement remains available via
rfc2822()orParseOptions::rfc5322()->withAllowObsLocalPart(true). Obs-dot testspec cases moved fromnormaltorelaxedmode to reflect where that behavior now lives.Empty quoted local-part (
""@domain) — bug fixrejectEmptyQuotedLocalPart(defaultfalse) now actually takes effect. Previously""@domainwas rejected asincomplete_addressby the state machine before the option was consulted: an empty quote leavesquote_tempempty, and the@handler used content-emptiness as its "was quoted" signal. The closing-quote handler now records the quote explicitly, and a display-name quote resets the flag so the real local-part stays unquoted ("John Doe" <j@x>→ local partj, not"j").Length limits — documented + tested
The RFC 5321 §4.5.3.1 octet limits can be disabled wholesale via
->withEnforceLengthLimits(false), or customized via->withLengthLimits(new LengthLimits(...)). This already worked; it's now covered by a test.Verification
91 → 94 tests (added dot-placement, empty-quoted toggle, length-disable), PHPStan level 8 / Psalm / cs all clean.
Follow-up (not in this PR)
The gold-standard differential surfaced a further ~20 over-acceptance edge cases (unclosed comments / domain-literals, atext-after-quoted-string, CR/LF & folding-whitespace strictness). Those are a separate, larger body of work.